
<template tag="以下文档内容为hycli自动生成">
  <el-dialog
    v-model="conf.visible"
    v-if="conf.visible" 
    :title="title"
   :width="conf.width"
    draggable
      align-center="true" 
    :close-on-click-modal="false"
  >
  <el-form :model="form"  ref="form" :rules="rules_aaabt">
    <el-row>
    <el-col :span="24">
    <!-- {"index":6,"raw":"name","name":"name","cname":"Name","type":{"raw":"varchar2(128)","name":"varchar2","len":128,"dlen":0},"defValue":"","allowNull":false,"constraints":["c","l","u","le","q","DN","v","DN","lnm","li","rows(1)","lw(180)","#like","fx"],"desc":{"raw":"名称","name":"名称"}} -->
    <!--名称 输入控件 -->
    <el-form-item prop="name" label="名称" label-width="100px" label-position="right">
      <el-input clearable style="width: 100%" v-model="form.name"  maxlength="128" 
      :rows="1"  type="textarea" show-word-limit  placeholder="请输入名称"  />
      </el-form-item>
    </el-col>
    <el-col :span="12">
    <!-- {"index":8,"raw":"priority","name":"priority","cname":"Priority","type":{"raw":"number(1)","name":"number","len":1,"dlen":0},"defValue":"0","allowNull":false,"constraints":["l","le","c","u","fq","li","v","sl(PRI)","tp(radio)","sws","color","rx","lw(80)","fx"],"desc":{"raw":"优先级  \u003cbr /\u003ep0 重大客情/政治任务/直接产生效益\u003cbr /\u003eP1 已承诺客户/关键系统功能\u003cbr /\u003eP2与营销/服务直接相关的\u003cbr /\u003eP3效率相关的","name":"优先级"}} -->
    <el-form-item prop="priority" label="优先级" label-width="100px" label-position="right">
      <el-radio-group v-model="form.priority"   >
        <el-radio-button v-for="item in priorityList" :key="item.value" :label="item.value" >
            {{item.name}}
        </el-radio-button>
      </el-radio-group>
      <el-tooltip raw-content="true" content="优先级  <br />p0 重大客情/政治任务/直接产生效益<br />P1 已承诺客户/关键系统功能<br />P2与营销/服务直接相关的<br />P3效率相关的" placement="bottom" effect="light">
      <i class="form_item_info fa fa-info-circle"  aria-hidden="true" />
      </el-tooltip>
    </el-form-item>
    </el-col>
    <el-col :span="12">
    <!-- {"index":9,"raw":"category","name":"category","cname":"Category","type":{"raw":"varchar2(32)","name":"varchar2","len":32,"dlen":0},"defValue":"","allowNull":false,"constraints":["l","le","c","u","v","fq","sl(prod_req_cateogry)","sws","tp(radio)","color","rx","fx","lidx(110)"],"desc":{"raw":"分类","name":"分类"}} -->
    <el-form-item prop="category" label="分类" label-width="100px" label-position="right">
      <el-radio-group v-model="form.category"   >
        <el-radio-button v-for="item in categoryList" :key="item.value" :label="item.value" >
            {{item.name}}
        </el-radio-button>
      </el-radio-group>
    </el-form-item>
    </el-col>
    <el-col :span="24">
    <!-- {"index":10,"raw":"source","name":"source","cname":"Source","type":{"raw":"number(2)","name":"number","len":2,"dlen":0},"defValue":"","allowNull":false,"constraints":["l","le","c","u","v","q","li","sl","tp(radio)","color","lw(120)","ps(full)","rx","fx"],"desc":{"raw":"来源","name":"来源"}} -->
    <el-form-item prop="source" label="来源" label-width="100px" label-position="right">
      <el-radio-group v-model="form.source"   >
        <el-radio-button v-for="item in sourceList" :key="item.value" :label="item.value" >
            {{item.name}}
        </el-radio-button>
      </el-radio-group>
    </el-form-item>
    </el-col>
    <el-col :span="24">
    <!-- {"index":12,"raw":"content","name":"content","cname":"Content","type":{"raw":"varchar2(2000)","name":"varchar2","len":2000,"dlen":0},"defValue":"","allowNull":false,"constraints":["q","c","le","u","v","li","rows(6)","#like","tp(rtext,c-u)","fx"],"desc":{"raw":"内容","name":"内容"}} -->
    <!--内容 输入控件 -->
    <el-form-item prop="content" label="内容" label-width="100px" label-position="right">
      <rtext :html="form.content" :rows="6" @onChange="onRtextcontentChange"></rtext>
    </el-form-item>
    </el-col>
    <el-col :span="24">
    <!-- {"index":13,"raw":"url","name":"url","cname":"Url","type":{"raw":"varchar2(255)","name":"varchar2","len":255,"dlen":0},"defValue":"","allowNull":true,"constraints":["le","c","u","v","rows(1)","tp(link,l-le-v)","tp(file,c-u)"],"desc":{"raw":"文档链接","name":"文档链接"}} -->
    <!--文档链接 文件控件 -->
    <el-form-item prop="url" label="文档链接" label-width="100px" label-position="right">
      <el-input clearable style="width: 100%" v-model="form.url"  maxlength="255" 
        :rows="1"   show-word-limit 
        placeholder="请输入文档链接地址或上传文件"  >
        <template #append>
          <el-upload multiple :show-file-list="false" :action="conf.uploadPath" :limit="100" :on-success="onUploadSuccess" >
            <el-button type="primary">选择文件</el-button>
          </el-upload>
        </template>
      </el-input>
    </el-form-item>
    </el-col>
    <el-col :span="24">
    <!-- {"index":16,"raw":"pmaster","name":"pmaster","cname":"Pmaster","type":{"raw":"number(8)","name":"number","len":8,"dlen":0},"defValue":"","allowNull":false,"constraints":["c","l","u","le","q","v","sl(pmaster,-,#lob_id)","fq","tp(radio)","tp(multiselect,q)","cpr","sws","ps(full)","lw(60)","color","fx"],"desc":{"raw":"产品","name":"产品"}} -->
    <el-form-item prop="pmaster" label="产品" label-width="100px" label-position="right">
      <el-radio-group v-model="form.pmaster"   >
        <el-radio-button v-for="item in pmasterList" :key="item.value" :label="item.value" >
            {{item.name}}
        </el-radio-button>
      </el-radio-group>
    </el-form-item>
    </el-col>
    <el-col :span="24">
    <!-- {"index":18,"raw":"prstatus","name":"prstatus","cname":"Prstatus","type":{"raw":"number(2)","name":"number","len":2,"dlen":0},"defValue":"","allowNull":false,"constraints":["l","c","le","q","u","v","sl","ps(full)","brpp","bw","DV(89)","tp(radio,c-u-rx-sws)","bcpr","prs","bc2zp","fq","tp(tag)","sws","color","rp","tp(xtabs,q,prstatus)","fx"],"desc":{"raw":"需求状态","name":"需求状态"}} -->
    <el-form-item prop="prstatus" label="需求状态" label-width="100px" label-position="right">
      <el-radio-group v-model="form.prstatus"   >
        <el-radio-button v-for="item in prstatusList" :key="item.value" :label="item.value" >
            {{item.name}}
        </el-radio-button>
      </el-radio-group>
    </el-form-item>
    </el-col>
    <el-col :span="12">
    <!-- {"index":19,"raw":"proposal_time","name":"proposal_time","cname":"ProposalTime","type":{"raw":"date","name":"date","len":0,"dlen":0},"defValue":"","allowNull":true,"constraints":["le","c","u","f(MM/dd)","q","tp(daterange,q)","li","v"],"desc":{"raw":"提出时间","name":"提出时间"}} -->
    <!--提出时间 日期控件 -->
    <el-form-item prop="proposal_time" label="提出时间" label-width="100px" label-position="right">
      <el-date-picker style="width: 100%" v-model="form.proposal_time" clearable type="date"
          placeholder="请选择提出时间" format="YYYY-MM-DD" value-format="YYYY-MM-DD"  :default-time="new Date($theia.str.dateFormat(new Date(),'MM/dd'))"/>
    </el-form-item>
    </el-col>
    <el-col :span="12">
    <!-- {"index":20,"raw":"expected_time","name":"expected_time","cname":"ExpectedTime","type":{"raw":"date","name":"date","len":0,"dlen":0},"defValue":"","allowNull":true,"constraints":["l","le","c","u","f(MM/dd)","q","tp(daterange,q)","li","v"],"desc":{"raw":"期望上线","name":"期望上线"}} -->
    <!--期望上线 日期控件 -->
    <el-form-item prop="expected_time" label="期望上线" label-width="100px" label-position="right">
      <el-date-picker style="width: 100%" v-model="form.expected_time" clearable type="date"
          placeholder="请选择期望上线" format="YYYY-MM-DD" value-format="YYYY-MM-DD"  :default-time="new Date($theia.str.dateFormat(new Date(),'MM/dd'))"/>
    </el-form-item>
    </el-col>
    <el-col :span="12">
    <!-- {"index":21,"raw":"req_ass_time","name":"req_ass_time","cname":"ReqAssTime","type":{"raw":"date","name":"date","len":0,"dlen":0},"defValue":"","allowNull":true,"constraints":["le","c","u","f(MM/dd)","q","tp(daterange,q)","v","sws","cpr","tp(datetime,c-u-sws-crp,yyyy/MM/dd 09:00:00)","rx","fx"],"desc":{"raw":"评估时间","name":"评估时间"}} -->
    <!--评估时间 日期控件 -->
    <el-form-item prop="req_ass_time" label="评估时间" label-width="100px" label-position="right">
      <el-date-picker style="width: 100%" v-model="form.req_ass_time" clearable type="datetime"
        placeholder="请选择评估时间" format="YYYY-MM-DD HH:mm:ss" value-format="YYYY-MM-DD HH:mm:ss" 
         :default-time="new Date($theia.str.dateFormat(new Date(),'yyyy/MM/dd 09:00:00'))"/>
    </el-form-item>
    </el-col>
    <el-col :span="12">
    <!-- {"index":22,"raw":"internal_ass_time","name":"internal_ass_time","cname":"InternalAssTime","type":{"raw":"date","name":"date","len":0,"dlen":0},"defValue":"","allowNull":true,"constraints":["le","c","u","f(MM/dd)","q","tp(daterange,q)","v","sws","cpr","tp(datetime,c-u-sws-crp,yyyy/MM/dd 09:00:00)","rx","fx"],"desc":{"raw":"内评时间","name":"内评时间"}} -->
    <!--内评时间 日期控件 -->
    <el-form-item prop="internal_ass_time" label="内评时间" label-width="100px" label-position="right">
      <el-date-picker style="width: 100%" v-model="form.internal_ass_time" clearable type="datetime"
        placeholder="请选择内评时间" format="YYYY-MM-DD HH:mm:ss" value-format="YYYY-MM-DD HH:mm:ss" 
         :default-time="new Date($theia.str.dateFormat(new Date(),'yyyy/MM/dd 09:00:00'))"/>
    </el-form-item>
    </el-col>
    <el-col :span="12">
    <!-- {"index":23,"raw":"tch_sol_ass_time","name":"tch_sol_ass_time","cname":"TchSolAssTime","type":{"raw":"date","name":"date","len":0,"dlen":0},"defValue":"","allowNull":true,"constraints":["le","c","u","f(MM/dd)","q","tp(daterange,q)","v","c2zp","sws","tp(datetime,c-u-sws,yyyy/MM/dd 09:00:00)","rx","fx"],"desc":{"raw":"正评时间","name":"正评时间"}} -->
    <!--正评时间 日期控件 -->
    <el-form-item prop="tch_sol_ass_time" label="正评时间" label-width="100px" label-position="right">
      <el-date-picker style="width: 100%" v-model="form.tch_sol_ass_time" clearable type="datetime"
        placeholder="请选择正评时间" format="YYYY-MM-DD HH:mm:ss" value-format="YYYY-MM-DD HH:mm:ss" 
         :default-time="new Date($theia.str.dateFormat(new Date(),'yyyy/MM/dd 09:00:00'))"/>
    </el-form-item>
    </el-col>
    <el-col :span="12">
    <!-- {"index":25,"raw":"sponsor","name":"sponsor","cname":"Sponsor","type":{"raw":"varchar2(32)","name":"varchar2","len":32,"dlen":0},"defValue":"","allowNull":false,"constraints":["le","c","q","u","v","li","fx"],"desc":{"raw":"发起人","name":"发起人"}} -->
    <!--发起人 输入控件 -->
    <el-form-item prop="sponsor" label="发起人" label-width="100px" label-position="right">
      <el-input clearable style="width: 100%" v-model="form.sponsor"  maxlength="32" 
      :rows="0"  placeholder="请输入发起人"  />
      </el-form-item>
    </el-col>
    <el-col :span="24">
    <!-- {"index":26,"raw":"memo","name":"memo","cname":"Memo","type":{"raw":"varchar2(200)","name":"varchar2","len":200,"dlen":0},"defValue":"","allowNull":true,"constraints":["c","le","u","v","rows(2)","lw(60)","rx","fx"],"desc":{"raw":"备注","name":"备注"}} -->
    <!--备注 输入控件 -->
    <el-form-item prop="memo" label="备注" label-width="100px" label-position="right">
      <el-input clearable style="width: 100%" v-model="form.memo"  maxlength="200" 
      :rows="2"  type="textarea" show-word-limit  placeholder="请输入备注"  />
      </el-form-item>
    </el-col>
    </el-row>
    </el-form>
    <template #footer>
      <span class="dialog-footer">
        <el-button @click="hide" icon="close">取消</el-button>
        <el-button type="primary" @click="save" icon="select">提交</el-button>
      </span>
    </template>
  </el-dialog>
</template>

<script>
import rtext from "@/views/cmpnts/rtext.vue"
export default {
  components: {
    rtext
},
  data() {
    return {
      conf: {
        title:"提需求",
        visible: false,
        width:this.$size.gt("m")?"50%":"70%",
        uploadPath:this.$theia.env.join("/file/upload"),
      },
rules_aaabt:{
    name:[{required:true,message:"请输入名称",trigger: 'blur'}],
    priority:[{required:true,message:"请输入优先级",trigger: 'blur'}],
    category:[{required:true,message:"请输入分类",trigger: 'blur'}],
    source:[{required:true,message:"请输入来源",trigger: 'blur'}],
    content:[{required:true,message:"请输入内容",trigger: 'blur'}],
    url:[{required:false,message:"请输入文档链接",trigger: 'blur'}],
    pmaster:[{required:true,message:"请输入产品",trigger: 'blur'}],
    prstatus:[{required:true,message:"请输入需求状态",trigger: 'blur'}],
    proposal_time:[{required:false,message:"请输入提出时间",trigger: 'blur'}],
    expected_time:[{required:false,message:"请输入期望上线",trigger: 'blur'}],
    req_ass_time:[{required:false,message:"请输入评估时间",trigger: 'blur'}],
    internal_ass_time:[{required:false,message:"请输入内评时间",trigger: 'blur'}],
    tch_sol_ass_time:[{required:false,message:"请输入正评时间",trigger: 'blur'}],
    sponsor:[{required:true,message:"请输入发起人",trigger: 'blur'}],
    memo:[{required:false,message:"请输入备注",trigger: 'blur'}],
  },
    form:{
        name:"",
        priority:"",
        category:"",
        source:"",
        content:"",
        url:"",
        pmaster:"",
        prstatus:"",
        proposal_time:"",
        expected_time:"",
        req_ass_time:"",
        internal_ass_time:"",
        tch_sol_ass_time:"",
        sponsor:"",
        memo:"",
    },
    priorityList:[],
    categoryList:[],
    sourceList:[],
    pmasterList:[],
    prstatusList:[],
    }
  },
  methods: {
    show(fm = {}) {
      this.title = fm.$title || this.title
      this.conf.visible = true;
      this.loadEnums_aaabt()
      let local = {}
      let cache = Object.assign(local,fm)
      this.form = Object.assign(cache,this.$route.params)
    },
    save(){
      this.$refs.form.validate((v=>{
          if(v) this.onSave()
      }))
    },
    onSave(){
        let that = this
        let postForm = Object.assign({},this.form)
        postForm.lob_id = this.$theia.user.get("lob_id")
        //保存数据
        this.$theia.http.post("/ws/prod/requirement",postForm).then(res=>{
            that.$notify.success({title: '成功',message: '需求管理保存成功',duration:5000})
            that.hide()
            that.$theia.enum.clear("prod_requirement")
            that.$emit("onsaved")
        }).catch(res=>{
            let code = ((res||{}).response||{}).status||0
            let msg= `需求管理保存失败(${code})`
            msg = code == 909? msg+"数据重复，请修改后重试":msg
            that.$notify.error({title: '失败',message:msg,duration:5000})
        })
    },
    hide() {
      this.conf.visible = false;
      this.$refs.form.resetFields();
    },
    onRtextcontentChange(text,urls){
      this.form.content = text
      this.form.content_urls = (urls||[]).join(",")
    },
    onUploadSuccess(response){
      this.form.url = response.path
    },
    loadEnums_aaabt(){
        //优先级
        this.priorityList = this.$theia.enum.get("PRI","","" ,false,"")
        //分类
        this.categoryList = this.$theia.enum.get("prod_req_cateogry","","" ,false,"")
        //来源
        this.sourceList = this.$theia.enum.get("source","","" ,false,"")
        //产品
        this.pmasterList = this.$theia.enum.get("pmaster","",this.$theia.user.get("lob_id"),false,"")
        //需求状态
        this.prstatusList = this.$theia.enum.get("prstatus","","" ,false,"")
    },

},
}
</script>

<style scoped>
.avatar-uploader .avatar {
  width: 80px;
  height: 80px;
  display: block;
}
.form_item_info{
  margin-left: 4px;
  color:#999;
}
.form_item_info:hover{
  cursor: pointer;
  font-weight: 500;
  color:#333;
}
</style>